package edu;

import java.io.IOException;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 * This class is the connector between browser and our defined objects (Board, Player, LetterBag) 
 * 
 */
public class GameHandler extends HttpServlet 
{
	/**
	 * function to deal with get request. When a request send to the server, which defined 
	 * as get method. This function will be called by the server. Here we can simply call
	 * doPost
	 */
	public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException 
	{
		// simply call doPost
		this.doPost(req, resp);
	}
	
	/**
	 * 
	 */
	public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException
	{
		// here we simply set the session and put some mapping attributes
		// into the session, then redirect the page to game.jsp. In game.jsp
		// we will fetch our attributes from the session, which we defined here
		//HttpSession session = req.getSession(true);
		// set values
		//session.setAttribute("welcome", "Hello World");
		// direct the page to game.jsp
		resp.sendRedirect("/game.jsp");
		
	}
	

}
